/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.agilelang.structure;


import java.io.File;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
 *
 * @author Roderick
 */
public class AppGenerator {

    
    String pathOut = "";
    String pathTmpl = "";
    AppConfig config;
   

    public AppGenerator( String pathTmpl, String pathOut) {
        
        this.pathTmpl = pathTmpl;
        this.pathOut = pathOut;
        try {
            config = (AppConfig) UtilFile.getProjectXML(this.pathTmpl + File.separator + "tmpl_app" + File.separator + "_app.xml", AppConfig.class);
        } catch (InstantiationException | IllegalAccessException ex) {
            
        }
        if(!config.structure.equals("")){
             UtilFile.unzip(pathTmpl + File.separator + "tmpl_app" + File.separator + config.structure, pathOut);  
        }            
        copyfiles();
    }

    public final void copyfiles() {
        List<FileStatic> files = config.file;
        for (int x = 0; x < files.size(); x++) {
            UtilFile.copyfile(pathTmpl + File.separator + "tmpl_app" + File.separator + files.get(x).origin, pathOut + File.separator + files.get(x).destination);
        }
    }
}
